import Vue from 'vue'
Vue.prototype.$websocket = function (data,func){
  let websocket = new WebSocket(domain.wsUrl);
  websocket.onopen = function(evt) {
    let s_obj = data;
    let s_json = JSON.stringify(s_obj);
    websocket.send(s_json);
  };
  websocket.onmessage = function(evt) {
    func(evt);
  };
  websocket.onclose = function(evt) {
    console.log("连接已关闭");
  };
  websocket.onerror = function(evt) {
    console.log("出错");
  };
};
